package pe.com.pgn.consolidadorventas.servidorestacion.util;

import java.io.IOException;

import org.apache.log4j.Logger;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

/**
 * @author John
 * //http://exampledepot.com/egs/java.net/Base64.html
 */
public class Base64Util {

	static Logger logger = Logger.getLogger(Base64Util.class);
	
	public static String convertirBytesStringBase64(byte[] buffer){
		  BASE64Encoder b64 = new BASE64Encoder();
		  String s = b64.encode(buffer);
		  return s;
	}
	
	public static byte[] convertirStringBase64Bytes(String cadena){
		 BASE64Decoder b64 = new BASE64Decoder();
		 byte[] buf = new byte[1024];
		 try {
			buf = b64.decodeBuffer(cadena);
		 } catch (IOException e) {
			LoggerUtil.error(logger,e.getMessage());
		 }
		 return buf;
	}
}
